<template>
  <div class="teaching-page">
    <!-- 顶部导航 -->
    <nav class="top-nav">
      <div class="nav-content">
        <div class="logo">中软国际教育</div>
        <div class="nav-right">
          <div class="icon-item"></div>
          <div class="icon-item">🔔</div>
          <div class="user-info">
            <span class="avatar">我</span>
            <span>我的学习</span>
          </div>
        </div>
      </div>
    </nav>

    <div class="main-container">
      <!-- 左侧菜单 -->
      <div class="left-menu">
        <div class="menu-item active">
          <i class="menu-icon">📚</i>
          <span>最近开课</span>
        </div>
        <div class="menu-item">
          <i class="menu-icon">📋</i>
          <span>课程管理</span>
        </div>
        <div class="menu-item">
          <i class="menu-icon">📦</i>
          <span>课程包</span>
        </div>
        <div class="menu-item">
          <i class="menu-icon">🎯</i>
          <span>培养方案</span>
        </div>
        <div class="menu-item">
          <i class="menu-icon">💪</i>
          <span>能力池管理</span>
        </div>
        <div class="menu-item">
          <i class="menu-icon">🧠</i>
          <span>知识域管理</span>
        </div>
      </div>

      <!-- 右侧内容区 -->
      <div class="content-area">
        <!-- 搜索框 -->
        <div class="search-bar">
          <input type="text" placeholder="搜索开课" class="search-input">
        </div>

        <!-- 课程列表 -->
        <div class="course-list">
          <div class="course-card" v-for="course in courses" :key="course.id" style="cursor: pointer;" @click="openCourse(course)">
            <div class="course-image" :style="{ backgroundColor: course.bgColor }">
              <div class="course-icon">{{ course.icon }}</div>
            </div>
            <div class="course-info">
              <div class="course-title">{{ course.name }}</div>
              <div class="course-time">开课时间: {{ course.startTime }}至{{ course.endTime }}</div>
              <div class="course-teacher">授课教师: {{ course.teacher }}</div>
              <div class="course-stats">
                <span class="stat-item">
                  <i class="stat-icon">📄</i>
                  文档{{ course.docs }}
                </span>
                <span class="stat-item">
                  <i class="stat-icon">🎥</i>
                  视频{{ course.videos }}
                </span>
                <span class="stat-item">
                  <i class="stat-icon">📝</i>
                  课堂{{ course.classes }}
                </span>
                <span class="stat-item">
                  <i class="stat-icon">✍️</i>
                  作业{{ course.homework }}
                </span>
                <span class="stat-item">
                  <i class="stat-icon">🔬</i>
                  实验{{ course.labs }}
                </span>
                <span class="stat-item">
                  <i class="stat-icon">📊</i>
                  实训{{ course.training }}
                </span>
                <span class="stat-item">
                  <i class="stat-icon">📝</i>
                  考试{{ course.exams }}
                </span>
                <span class="stat-item">
                  <i class="stat-icon">👥</i>
                  学生{{ course.students }}
                </span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()

const courses = ref([
  {
    id: 1,
    name: '八年级-八年级一班',
    startTime: '2024-12-01',
    endTime: '2024-12-01',
    teacher: '田思泽',
    bgColor: '#40B883',
    icon: '👨‍💻',
    docs: 2,
    videos: 0,
    classes: 2,
    homework: 0,
    labs: 0,
    training: 1,
    exams: 0,
    students: 10
  },
  {
    id: 2,
    name: '九年级-九年级一班',
    startTime: '2024-12-02',
    endTime: '2024-12-02',
    teacher: '田思泽',
    bgColor: '#6E7FF3',
    icon: '💻',
    docs: 4,
    videos: 0,
    classes: 2,
    homework: 0,
    labs: 0,
    training: 0,
    exams: 0,
    students: 9
  }
])

const openCourse = (course) => {
  const baseUrl = window.location.origin
  const path = router.resolve({
    name: 'CourseDetail',
    params: { id: course.id }
  }).href
  window.open(baseUrl + path, '_blank')
}
</script>

<style scoped>
.teaching-page {
  min-height: 100vh;
  background-color: #f5f7fa;
}

.top-nav {
  height: 60px;
  background-color: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.nav-content {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.logo {
  font-size: 18px;
  font-weight: bold;
  color: #002fa7;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.icon-item {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.3s;
}

.icon-item:hover {
  background-color: #f5f7fa;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.avatar {
  width: 32px;
  height: 32px;
  background-color: #002fa7;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-container {
  display: flex;
  padding-top: 20px;
}

.left-menu {
  width: 200px;
  background-color: white;
  padding: 20px 0;
  border-radius: 8px;
  margin-left: 20px;
}

.menu-item {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.3s;
  color: #666;
}

.menu-item:hover, .menu-item.active {
  background-color: #f0f7ff;
  color: #002fa7;
}

.content-area {
  flex: 1;
  padding: 0 20px;
}

.search-bar {
  margin-bottom: 20px;
}

.search-input {
  width: 300px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid #ddd;
  border-radius: 4px;
  outline: none;
}

.search-input:focus {
  border-color: #002fa7;
  box-shadow: 0 0 0 2px rgba(0, 47, 167, 0.1);
}

.course-list {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.course-card {
  background-color: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.course-image {
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.course-icon {
  font-size: 48px;
}

.course-info {
  padding: 16px;
}

.course-title {
  font-size: 16px;
  font-weight: bold;
  color: #333;
  margin-bottom: 8px;
}

.course-time, .course-teacher {
  font-size: 14px;
  color: #666;
  margin-bottom: 8px;
}

.course-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: #666;
}
</style> 